package week_home_work02;

import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/23
 */
public class Demo49 {
    public static void main(String[] args) {
        //设计一个程序，输出1到n之间所有素数的平方和。
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字:");
        int num = sc.nextInt();
        int sum  = 0;
        for (int i = 2; i <= num; i++) {
            boolean flag  = true;
            for (int j = 2; j <=Math.sqrt(i) ; j++) {
                if (i % j == 0){
                    flag =false;
                    break;
                }
            }

            if (flag){
                System.out.print(i+"\t");
                sum += i;
            }
        }
        System.out.println();
        System.out.println(sum);
    }
}
